<template>
  <div >
    <el-card class="box-card">
<!--    <el-collapse v-model="activeNames" @change="handleChange">-->
<!--      <el-collapse-item  name="1"  >-->
<!--        <template #title>-->
<!--          <div class="shijianzhaiyao">事件摘要</div>-->
<!--        </template>-->
        <el-form ref="form" :model="form" class="form-label" label-width="150px" >
          <div class="shijianyangshi">事件摘要</div>
          <div class="xian"></div>
          <div style="margin-top: 20px;">
        <el-form-item label="事件描述和事情经过" prop="discussionDepartmentDate"   >
          <div style="color: #4d89dd; font-size:14px"  >
            {{form.situationEdescriptionProcess}}
          </div>
        </el-form-item>
        <div class="line" />
        <el-form-item label="填报人"  prop="discussionSite">
          <div style="color: #4d89dd;font-size:14px" >
            {{form.reportFiller}}
          </div>
        </el-form-item>
        <div class="line" />
        <el-form-item label="发生时间" prop="discussionPanelist">
          <div style="color: #4d89dd;font-size:14px"  >
            {{form.occurrenceTime}}
          </div>
        </el-form-item>
        <el-form-item label="事件状态" prop="discussionPanelist">
          <div style="color: #4d89dd;font-size:14px"  >
            <dict-tag style="color: #4d89dd" :options="dict.type.he_report_event_state" :value="form.reportEventState"/>
          </div>
        </el-form-item>
        <el-form-item label="事件严重程度" prop="discussionPanelist">
          <!--          <div style="color: #4d89dd"  >-->
          <!--            {{form.resultsEventSeverity}}-->
          <!--          </div>-->
          <div class="block"  >
<!--            A级:客观环境或条件可能引发不良事件(不良事件隐患)-->
            <el-tag class="el-tag" v-if="form.resultsEventSeverity==='01'" type="success">
            <dict-tag :options="dict.type.he_event_severity" :value="form.resultsEventSeverity"/>
            </el-tag>
            <el-tag class="el-tag" v-if="form.resultsEventSeverity==='02'||form.resultsEventSeverity==='03'||form.resultsEventSeverity==='04'">
              <dict-tag :options="dict.type.he_event_severity" :value="form.resultsEventSeverity"/>
            </el-tag>
            <el-tag style="background-color:#FFF68F;border-color:#fff1cc;" class="el-tag" v-if="form.resultsEventSeverity==='05'||form.resultsEventSeverity==='06'||form.resultsEventSeverity==='07'||form.resultsEventSeverity==='08'" type="warning">
              <dict-tag style="color:#CD9B1D;" :options="dict.type.he_event_severity" :value="form.resultsEventSeverity"/>
            </el-tag>
            <el-tag class="el-tag" v-if="form.resultsEventSeverity==='09'" type="danger">
              <dict-tag :options="dict.type.he_event_severity" :value="form.resultsEventSeverity"/>
            </el-tag>

            </div>
          </el-form-item>
          <el-form-item label="事件分级" prop="discussionPanelist">
            <div class="block"  >
              <!--            IV级事件:错误未发生(错误隐患)(包括损害程度A级)-->
              <el-tag class="el-tag" v-if="form.resultsEventClassification==='04'" type="success">
                <dict-tag :options="dict.type.he_event_classification" :value="form.resultsEventClassification"/>
              </el-tag>
              <!--            Ⅲ级事件:发生错误，但未造成患者伤害(包括损害程度B、C、D级)-->
              <el-tag class="el-tag" v-if="form.resultsEventClassification==='03'">
                <dict-tag :options="dict.type.he_event_classification" :value="form.resultsEventClassification"/>
              </el-tag>
              <!--            Ⅱ级事件:发生错误，且造成患者伤害(包括损害程度E、F、G、H级)-->
              <el-tag style="background-color:#FFF68F;border-color:#fff1cc;"  class="el-tag" v-if="form.resultsEventClassification==='02'" type="warning">
                <dict-tag style="color:#CD9B1D;" :options="dict.type.he_event_classification" :value="form.resultsEventClassification"/>
              </el-tag>
              <!--            I级事件:发生错误，造成患者死亡(包括损害程度I级)-->
              <el-tag class="el-tag" v-if="form.resultsEventClassification==='01'" type="danger">
                <dict-tag :options="dict.type.he_event_classification" :value="form.resultsEventClassification"/>
              </el-tag>
            </div>
          </el-form-item>
          <el-form-item label="伤害严重度" prop="discussionPanelist">
            <div class="block"  >
              <dict-tag style="color: #4d89dd" :options="dict.type.he_severity_of_injury" :value="form.resultsSeverityInjury"/>
            </div>
          </el-form-item>
        </div>
      </el-form>

<!--      </el-collapse-item>-->
<!--    </el-collapse>-->

      <el-form ref="form1" :rules="rules" :model="form" label-width="150px" >
        <div class="shijianyangshi">事件呈送</div>
        <div class="xian"></div>
        <div style=" margin-top: 20px">
          <el-row>
            <el-col :span="5.5">
              <el-form-item label="事件判定" prop="reviewEventType"  >
                <el-select  v-model="form.reviewEventType" placeholder="请选择">
                  <el-option
                    v-for="dict in dict.type.he_review_event_type"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="5.5">
              <el-form-item label="呈送部门" prop="reviewDepartment"  >
                <el-select filterable  v-model="form.reviewDepartment" placeholder="请选择">
                  <el-option
                    v-for="dict in dict.type.he_department_name"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="5.5">
              <el-form-item  label="匿名上报" prop="note10"  >
                <el-select  v-model="form.note10" placeholder="请选择" >
                  <el-option
                    v-for="dict in dict.type.he_anonymous_status"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="5.5">
              <el-form-item  label="填报部门"  prop="reportDepartment">
               <span style="font-size: 18px;color: #E65D6E"  class="bold-text">
                   <dict-tag :options="dict.type.he_department_name" :value="form.reportDepartment"/>
               </span>
              </el-form-item>
            </el-col>
          </el-row>
          <div class="line" />
          <el-form-item >
                <el-button  style="margin-left: 14%"  type="primary" @click.prevent.native="shangbao" plain>上报</el-button>
          </el-form-item>
        </div>
      </el-form>
    </el-card>
  </div>
</template>

<script>
import {  getReport, delReport,updateReport } from "@/api/module/shao/shijian/report";

export default {
  name: "Report",
  inject:['reload'],
  dicts: ['he_severity_of_injury','he_anonymous_status','he_department_name','he_event_severity','he_education', 'he_patient_gender', 'he_party_post', 'he_report_event_state', 'he_report_event_type', 'he_patient_age_grades', 'he_event_severity', 'he_review_status', 'he_report_status', 'he_position', 'he_event_classification', 'he_review_event_type', 'he_possibility_of_dispute', 'he_patient_involved', 'he_analyze_reports', 'he_fallback_status', 'he_occurrence_time_period', 'he_event_determinatione', 'he_situation_measures_event', 'he_patient_education_level', 'he_diagnosis_category', 'he_years_of_experience', 'he_severity_of_injury', 'he_reporting_method', 'he_patient_nursing_level', 'he_date_type', 'he_invalidation_status', 'he_patient_ethnic_group', 'he_category', 'he_handling_status'],
  data() {
    return {
      close:true,
      activeNames: ['1'],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 事件上报信息表格数据
      reportList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 表单参数
      form: {
        note10:null,
        reviewDepartment:null
      },
      // 表单校验
      rules: {
        reviewEventType:[{
          required:true,message:"事件判定不能为空"
        }],
        reviewDepartment:[{
          required:true,message:"呈送科室不能为空"
        }],
        note10:[{
          required:true,message:"匿名上报不能为空"
        }],

      }
    };
  },
  created() {
    getReport(this.$route.query.id).then(response => {
      this.form = response.data;
    });
  },
  methods: {
    shangbao() {
      this.$refs["form1"].validate(valid=>{
        if(valid){
          if(this.form.reviewDepartment==undefined||this.form.reviewDepartment==""){
            this.$modal.msgError("请选择呈送科室后进行上报！");
            //const obj = { path: "/hosipitalevent/caogaoshijian" };
            //this.$tab.closeOpenPage(obj);
            /*this.$router.push({path: "/hosipitalevent/caogaoshijian"});*/
          }else{
            this.form.reportStatus = '02'
            if(this.form.note10=="02"){
              var self = this;
              this.$modal.confirm('请确认是否匿名上报事件，上报后本人将不可见').then(function() {
                updateReport(self.form).then(response => {
                  // 返回上一页
                  const obj = { path: "/hosipitalevent/caogaoshijian" };
                  self.$tab.closeOpenPage(obj);

                });
              }).then(() => {
                this.$modal.msgSuccess("匿名上报成功");
              }).catch(() => {});

            }else{

              updateReport(this.form).then(response => {
                this.$modal.msgSuccess("上报成功");
                // 返回上一页

                const obj = { path: "/hosipitalevent/caogaoshijian" };
                this.$tab.closeOpenPage(obj);

              });
            }

          }

        }
      });


    },
  }
};
</script>
<!--<style lang="scss" scoped>-->
<!--.shijianzhaiyao {-->

<!--  font-weight: bold;-->
<!--  font-size: 18px;-->
<!--  margin-left: 14px;-->


<!--}-->
<!--//-->




<!--</style>-->
<style lang="scss" scoped>
//@import "src/views/module/shao/blackFont";
.shijianyangshi{
  font-weight: bold;
  font-size: 20px;
  color: #000000;
  text-align: left;
}
.xian{
  border-bottom: 1px solid #ebebeb;
  margin-top: 0.5%;
}
.el-tag{
  font-size: 14px;
}
.form-label{
::v-deep .el-form-item__label{
  font-size: 15px;
  font-weight: bold;
}
}
.bold-text {
  font-weight: bold;
}

</style>


